package com.soft.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.soft.common.core.domain.R;
import com.soft.manage.domain.dto.smsMessageDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.soft.common.annotation.Log;
import com.soft.common.core.controller.BaseController;
import com.soft.common.core.domain.AjaxResult;
import com.soft.common.enums.BusinessType;
import com.soft.manage.domain.RuanzhuApplyInfo;
import com.soft.manage.service.IRuanzhuApplyInfoService;
import com.soft.common.utils.poi.ExcelUtil;
import com.soft.common.core.page.TableDataInfo;

/**
 * 软著申请情况Controller
 *
 * @author mobin
 * @date 2025-06-04
 */
@RestController
@RequestMapping("/manage/ruanzhuInfo")
public class RuanzhuApplyInfoController extends BaseController {
    @Autowired
    private IRuanzhuApplyInfoService ruanzhuApplyInfoService;

    /**
     * 查询软著申请情况列表
     */
    @PreAuthorize("@ss.hasPermi('manage:ruanzhuInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(RuanzhuApplyInfo ruanzhuApplyInfo) {
        startPage();
        List<RuanzhuApplyInfo> list = ruanzhuApplyInfoService.selectRuanzhuApplyInfoList(ruanzhuApplyInfo);
        return getDataTable(list);
    }

    /**
     * 导出软著申请情况列表
     */
    @PreAuthorize("@ss.hasPermi('manage:ruanzhuInfo:export')")
    @Log(title = "软著申请情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RuanzhuApplyInfo ruanzhuApplyInfo) {
        List<RuanzhuApplyInfo> list = ruanzhuApplyInfoService.selectRuanzhuApplyInfoList(ruanzhuApplyInfo);
        ExcelUtil<RuanzhuApplyInfo> util = new ExcelUtil<RuanzhuApplyInfo>(RuanzhuApplyInfo.class);
        util.exportExcel(response, list, "软著申请情况数据");
    }

    /**
     * 获取软著申请情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:ruanzhuInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ruanzhuApplyInfoService.selectRuanzhuApplyInfoById(id));
    }

    /**
     * 新增软著申请情况
     */
    @PreAuthorize("@ss.hasPermi('manage:ruanzhuInfo:add')")
    @Log(title = "软著申请情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RuanzhuApplyInfo ruanzhuApplyInfo) {
        return toAjax(ruanzhuApplyInfoService.insertRuanzhuApplyInfo(ruanzhuApplyInfo));
    }

    /**
     * 修改软著申请情况
     */
    @PreAuthorize("@ss.hasPermi('manage:ruanzhuInfo:edit')")
    @Log(title = "软著申请情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RuanzhuApplyInfo ruanzhuApplyInfo) {
        return toAjax(ruanzhuApplyInfoService.updateRuanzhuApplyInfo(ruanzhuApplyInfo));
    }

    /**
     * 删除软著申请情况
     */
    @PreAuthorize("@ss.hasPermi('manage:ruanzhuInfo:remove')")
    @Log(title = "软著申请情况", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ruanzhuApplyInfoService.deleteRuanzhuApplyInfoByIds(ids));
    }

    /**
     * 发送短信
     */
    @Log(title = "发送短信", businessType = BusinessType.SEND)
    @PostMapping("/sendMessage")
    public R<Object> sendMessage(@RequestBody smsMessageDto smsMessageDto) {
        ruanzhuApplyInfoService.sendMessage(smsMessageDto);
        return R.ok();
    }
}
